package cn.lisens.thymeleaf.web;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.lisens.thymeleaf.entity.Product;
import cn.lisens.thymeleaf.entity.User;

@Controller
@RequestMapping("/user")
public class UserController {
	
	private List<User> users = new ArrayList<>();

	@RequestMapping("/")
	public String index(Model model) {
		model.addAttribute("message", "你好");
		model.addAttribute("users", users);
        return "user/list";
	}
	
	@RequestMapping("/form")
	public String form(User user,Model model) {
		model.addAttribute("user", user);
        return "user/form";
	}
	
	@RequestMapping("/save")
	public String save(User user,Model model) {
		users.add(user);
        return "redirect:/";
	}
}
